/*
 * SAMainView.cpp
 *
 *  Created on: 2010-06-04
 *      Author: NONO
 */

// INCLUDE FILES
#include <e32std.h>
#include <aknviewappui.h>
#include <avkon.hrh>
#include <eikmenup.h>                           // CEikMenuPane
#include <sslerr.h>                             // KErrSSLAlertCertificateExpired       


#include <SMSAssist_0xEB692DC8.rsg>
#include "SAMainView.h"
#include "SAMainContainer.h" 
#include "SAAppUi.h"
#include "SA.hrh"
       


// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// CPaMainView::ConstructL(const TRect& aRect)
// EPOC two-phased constructor
// ---------------------------------------------------------
//
void CSAMainView::ConstructL()
{
    BaseConstructL( R_SA_MAINVIEW );
    iFirstTime = ETrue;
}

// ---------------------------------------------------------
// CPaView::~CPaView()
// destructor
// ---------------------------------------------------------
//
CSAMainView::~CSAMainView()
{
    if ( iContainer )
    {
        AppUi()->RemoveFromViewStack( *this, iContainer );
    }
    delete iContainer;
}

// ---------------------------------------------------------
// TUid CSAMainView::Id()
//
// ---------------------------------------------------------
//
TUid CSAMainView::Id() const
{
    return TUid::Uid(ESAMainViewId);
}

// ---------------------------------------------------------
// CSAMainView::HandleCommandL(TInt aCommand)
// takes care of view command handling
// ---------------------------------------------------------
//
void CSAMainView::HandleCommandL(TInt aCommand)
    {  
     
    AppUi()->HandleCommandL( aCommand );
    }

// ---------------------------------------------------------
// CSAMainView::HandleClientRectChange()
// ---------------------------------------------------------
//
void CSAMainView::HandleClientRectChange()
{
    if ( iContainer )
    {
        iContainer->SetRect( ClientRect() );
    }
}

// ---------------------------------------------------------
// CSAMainView::DoActivateL(...)
// 
// ---------------------------------------------------------
void CSAMainView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
{
    if (!iContainer)
    {
        iContainer = new (ELeave) CSAMainContainer(*saAppUi);
        iContainer->SetMopParent(this);
        iContainer->ConstructL( ClientRect() );
        AppUi()->AddToStackL( *this, iContainer );
    }
}

// ---------------------------------------------------------
// CSAMainView::DoDeactivate()
// 
// ---------------------------------------------------------
//
void CSAMainView::DoDeactivate()
{
    if ( iContainer )
    {
        AppUi()->RemoveFromViewStack( *this, iContainer );
    }

    delete iContainer;
    iContainer = NULL;
}

void CSAMainView::DynInitMenuPaneL(
    TInt aResourceId, CEikMenuPane* aMenuPane )
    {
        AppUi()->DynInitMenuPaneL(aResourceId,aMenuPane);
    }
    
void CSAMainView::RedrawNow()
{
    iContainer->RedrawNow();
//    
}

void CSAMainView::WhetherInitSetup()
{
//    // First time dialog
//    if ( paAppUi->iSettings.RemoteCode() == KNullDesC() )
//    {
//        iIsRemoteCode = ETrue;
//        iTimerReason = EReasonOther;
//        iTimer->SetTime(KOneSecond/2);
//    }
//    // modified by Sandy 2008-2-29
//    else if (!paAppUi->iSettings.IsRuntimePasswordProtectionInitialed())
//    {
//        iIsRuntimePasswordProtection = ETrue;
//
//        iIsRemoteCode = EFalse;
//        iFirstTime = EFalse;
//        iTimerReason = EReasonOther;
//        iTimer->SetTime(KOneSecond/2);
//    }   
//    else if (!paAppUi->iSettings.IsNotificationSimChgInitialed())
//    {
//        iIsNotificationSimChg = ETrue;
//
//        iIsRemoteCode = EFalse;
//        iIsRuntimePasswordProtection = EFalse;
//        iFirstTime = EFalse;
//        iTimerReason = EReasonOther;
//        iTimer->SetTime(KOneSecond/2);
//    }
//    //
//    else if ( (paAppUi->iSettings.ManagePhoneNumber() == KNullDesC()) && iFirstTime)
//    {
//        iIsRemoteCode = EFalse;
//        iIsRuntimePasswordProtection = EFalse;
//        iIsNotificationSimChg = EFalse;
//        iFirstTime = EFalse;
//        iTimerReason = EReasonOther;
//        iTimer->SetTime(KOneSecond/2);
//    }
}


